home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 1181 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  3.1 KB

  1. From: "Nathan Myers <ncm@cantrip.org>" <ncm@cantrip.org>
  2. Message-ID: <3179534C.508B295B@cantrip.org>
  3. X-Original-Date: Sat, 20 Apr 1996 14:12:44 -0700
  4. Path: in2.uu.net!bounce-back
  5. Date: 21 Apr 96 06:57:08 GMT
  6. Approved: fjh@cs.mu.oz.au
  7. Newsgroups: comp.std.c++
  8. Subject: Re: auto_ptr problems
  9. Organization: Best Internet Communications
  10. References: <4l0uib$snf@netlab.cs.rpi.edu> <4l3ujn$cl5@netlab.cs.rpi.edu> <4l86m8$s53@netlab.cs.rpi.edu> <4l9vb5$665@mulga.cs.mu.OZ.AU>
  11. X-Mailer: Mozilla 2.01 (X11; I; Linux 1.2.13 i386)
  12. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  13.     iQBFAgUBMXncWuEDnX0m9pzZAQHBEAF/eCxdJI4dyTORNo5pLN6x/3HE9O1Ors12
  14.     kHmILiUGCEnLlgJ0qUCzZ9HLqIWpIkij
  15.     =nfVW
  16.  
  17. Fergus Henderson wrote:
  18. > In comp.lang.c++.moderated, kanze@gabi-soft.fr (J. Kanze) writes:
  19. > >"Nathan Myers" <ncm@cantrip.org> writes:
  20. > >
  21. > >|> The Draft standard requires that your compiler not try to generate
  22. > >|> auto_ptr::operator->() unless you use it.
  23. > [...]
  24. > >The requirement in the draft that Nathan is referring to (and which *is*
  25. > >new, and not supported by many compilers) is that they not check the
  26. > >return type of operator-> *unless* they actual have to generate the
  27. > >function.  (I'm not sure of the exact words, but that is more or less
  28. > >the meaning.)
  29. > I'm sure you're right, but when I had a look for this in the draft
  30. > standard, I couldn't find it.  Could anyone please direct me to the
  31. > appropriate place?
  32.  
  33. Actually, the language is a lot broader than James suggests. The WP
  34. places no restrictions on the return type of operator->, as such; it 
  35. only defines the meaning of the expression -> in terms of that return 
  36. type.  This implies that it is at the call site that an error has 
  37. occurred, if you try to apply "a->b" where a.operator->() returns 
  38. something that doesn't have a member b. 
  39.  
  40. (In fact, it doesn't say that, if you do use it, it needs to return
  41. a pointer.  That is, if X::operator->() returned a Y&, and Y defines
  42. Y::operator->(), then x->m could mean x.operator->().operator->m.
  43. I don't know of any compilers that support this (yet).)
  44.  
  45. The language in the post-Santa Cruz mailing is in 14.7.1, paragraph 6:
  46. "An implementation shall not implicitly instantiate a ... non-virtual
  47. member function ... that does not require instantiation."
  48.  
  49. Many current compilers generate the code for all member functions when
  50. the class is instantiated, and then report an error if some unused member
  51. uses an operation not defined for the template argument instantiated on.
  52.  
  53. So if your compiler doesn't support auto_ptr<int>::operator->(), it's
  54. broken on several counts even before we start talking about template
  55. constructors.  But that's life before the Standard.
  56.  
  57. Nathan Myers
  58. ncm@cantrip.org  http://www.cantrip.org/
  59. ---
  60. [ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
  61. [ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
  62. [ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
  63. [ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
  64. [ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]
  65.